package controller

import (
	"net/http"

	"github.com/gin-gonic/gin"
)

var ParamsError = 4000
var AuthError = 4001
var UserNotFound = 4002
var PasswordError = 4003
var BusinessError = 4004

type Result struct {
	Code    int         `json:"code"`
	Data    interface{} `json:"data"`
	Message string      `json:"message"`
}

// 请求成功
func Success(c *gin.Context, data interface{}) {

	c.JSON(http.StatusOK, Result{
		Code:    0,
		Data:    data,
		Message: "请求成功",
	})
}

// 请求失败
func Fail(c *gin.Context, code int, message string) {
	c.JSON(http.StatusOK, Result{
		Code:    code,
		Data:    "",
		Message: message,
	})
	c.Abort()
}
